package tools;

import com.alibaba.fastjson.JSON;

public class Result {
    private int code;       //状态码：200，500
    private String msg;     //消息：200_成功,500_编译失败
    private int  count;     //记录条数
    private Object data;    //数据对象

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

    public String toStringWithDateFormat(String dataFormat) {
        return JSON.toJSONStringWithDateFormat(this,dataFormat);
    }

    public Result(int code, String msg, int count, Object data) {
        this.code = code;
        this.msg = msg;
        this.count = count;
        this.data = data;
    }

    public Result(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Result(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result() {
    }

//    @Override
//    public String toString() {
//        return "Result{" +
//                "code=" + code +
//                ", msg='" + msg + '\'' +
//                ", count=" + count +
//                ", data=" + data +
//                '}';
//    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
